package com.yxw.bamboo.core.send.event;

import com.yxw.bamboo.core.NetworkContext;
import com.yxw.bamboo.core.spring.SpringUtil;
import org.springframework.stereotype.Component;

/**
 * 发送事件工厂
 */
@Component
public class SendEventListenerFactory {

    public SqlEventListener createBefore(NetworkContext networkContext)
    {
        if(networkContext.getSqlType().equals("mysql"))
        {

           return (SqlEventListener)SpringUtil.getBean("defaultBeforeMySqlEventListenerImpl");
        }

        if(networkContext.getSqlType().equals("mssql"))
        {

            if(networkContext.getCodeType().equals("net"))
            {
//                if(networkContext.getCommonType().equals("proc"))
//                {
//                    return (SqlEventListener)SpringUtil.getBean("defaultBeforeMsNetProcSqlEventListenerImpl");
//                }
                return (SqlEventListener)SpringUtil.getBean("defaultBeforeMsNetSqlEventListenerImpl");
            }

            return (SqlEventListener)SpringUtil.getBean("defaultBeforeMsSqlEventListenerImpl");
        }

        return null;
    }

    public SqlEventListener createAfter(NetworkContext networkContext)
    {
        if(networkContext.getSqlType().equals("mysql"))
        {
            return (SqlEventListener)SpringUtil.getBean("defaultAfterMySqlEventListenerImpl");
        }
        return null;
    }



}
